tinymce.init({
    selector: '.editor-area',  //生效的选择器，css语法
    language: 'zh_CN',
    theme: 'modern',
    inline: false, //行内编辑，配合selector选择可编辑的div
    height: 300,  //编辑器默认高度
    body_class: 'editor-content-body', //内容体样式名，配合样式文件可以自定义样式
    //content_css: '/js/tinymce/editor_content.css', //内容样式文件，配置该项，可以避免前后端样式不统一
    plugins: ['code preview fullscreen textcolor colorpicker', //code源代码编辑，preview预览，fullscreen全屏编辑，textcolor colorpicker文字颜色选取
        'lists advlist charmap hr link media table image ', //插入lists advlist列表，charmap特殊符号,hr水平线，link链接，media视频，image图片，table表格,
        'paste searchreplace visualblocks visualchars wordcount' //paste粘贴Word文档，searchreplace查找替换,,visualblocks显示区块网格visualchars显示不可见字符wordcount字符统计
    ],
    menubar: false, //关闭菜单栏
    toolbar: [ //工具栏
        'undo redo | bullist numlist link image media table hr charmap | searchreplace visualblocks visualchars | fullscreen code preview ',
        'removeformat styleselect fontsizeselect forecolor backcolor | bold,italic,underline,strikethrough | alignleft aligncenter alignright | outdent indent ',
    ],
    /*定义字体大小*/
    fontsize_formats: '10px 12px 14px 16px 18px 20px 22px 24px 26px 28px 30px',
    /**
     * 图片上传文档
     * https://www.tinymce.com/docs/get-started/upload-images/
     * */
    image_advtab: true, //image插件开启高级选项
    images_upload_url: ctx +'/upload/textUploadImg', //图片上传的服务器地址
    images_upload_credentials: true, //客户端身份
    images_upload_handler: function (blobInfo, success, failure) //上传处理
    {
        var xhr, formData;
        xhr = new XMLHttpRequest();
        xhr.withCredentials = true;
        xhr.open('POST', '/upload/textUploadImg');
        xhr.onload = function () {
            var json;

            if (xhr.status !== 200) {
                failure('网络错误: ' + xhr.status);
                return;
            }
            json = JSON.parse(xhr.responseText);
            //处理服务端返回的json,默认认为返回的data属性就是图片地址，简单处理
            var data = json;
            if (!json || json.error== 'true') {
                failure('上传失败,请稍后重试: ' + xhr.responseText);
                return;
            }
            //插入图片到编辑器
            success(json.path);
        };

        formData = new FormData();
        formData.append('imgFile', blobInfo.blob());
        xhr.send(formData);
    },
});